<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        // 递推表达式
        // f(n) = f(n-1) + f(n-2)
        //终止条件
        // n>=2;
        // [1,1,2,3,5,8,13,21,34,55,89]
        let cath = [0,1,1];
        function fbnx(n){
                if(cath[n]){
                    return cath[n]
                }
                return cath[n]=fbnx(n-1) + fbnx(n-2)
            
        }
        // console.log(fbnx(4))
        // console.log(fbnx(5))
        // console.log(fbnx(6))
        // console.log(fbnx(7))
        // console.log(fbnx(8))
        // console.log(fbnx(9))

        var consecutiveNumbersSum = function(N) {
            var ans = 0;
            for (var start = 1; start < N; ++start) {
                var target = N, x = start;
                while (target > 0){
                    target = target-x;
                    x++
                    if (target == 0) {
                        ans++;
                        console.log(start,x-1)
                    }
                }
                
            }
            return ans;
        };
        consecutiveNumbersSum(15)
    </script>
</body>
</html>